package com.bk.service.tranInfo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bk.entity.AccountBalance;
import com.bk.entity.CardInfo;
import com.bk.entity.TranFlowInfo;
import com.bk.mapper.cardInfo.CardInfoMapper;
import com.bk.mapper.tranInfo.TranInfoMapper;
import com.bk.util.Md5Util;
import com.bk.util.ReturnUtil;

@Service/**流水信息服务@author czl*/
public class TranInfoService {

	@Autowired
	public TranInfoMapper tranInfoMapper;
	
	@Autowired
	private CardInfoMapper cardInfoMapper;

	/**根据类型查找交易流水*/
	public ReturnUtil<TranFlowInfo> queryTranInfoByTranType(String cardId, String tranType) {
		CardInfo cardInfo=cardInfoMapper.isExistCardByAccountId(cardId);//通过账号查询是否有该账户  或者是否被冻结
		if(null==cardInfo) {
			return new ReturnUtil<TranFlowInfo>(400,"该账户已被冻结,请前往解冻",null);
		}else {
			List<TranFlowInfo> tranFlowInfoList=tranInfoMapper.queryTranInfoByTranType(cardId,tranType);
			if(tranFlowInfoList.size()>0) {
				if("4".equals(tranType)) {
					for(TranFlowInfo tranInfo:tranFlowInfoList) {
						tranInfo.setTranType(Integer.parseInt(tranType));
					}
				}
				return new ReturnUtil<TranFlowInfo>(200,"记录查询成功",tranFlowInfoList);
			}else {
				return new ReturnUtil<TranFlowInfo>(400,"查询无记录",null);
			}
		}
	}
	
}
